<?php
/**
 * Created by PhpStorm.
 * User: 毛文科
 * Date: 2018\10\28 0028
 * Time: 10:03
 */
namespace app\admin\model;
use think\Config;
use think\Db;

class Fields
{
    public static function add($data){
        $modelid = $data['modelid'];
        $resul = Db::connect();
        $table   = \config('database.prefix').($resul->name('model')->where('id',$modelid)->find())['surface'];
        $sql = 'alter table '.$table.' add '.$data['field_title'].' '.$data['types'];
        if(!($data['types']=='text')){
            $sql = $sql.'(255) not null';
        }
        $bool = $resul->query($sql);
        return $bool;
    }
}